package com.deep.provider.controller;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.TimeUnit;

@RestController
public class ProviderController {

    @GetMapping("/provider/{name}")
    public String echo(@PathVariable(name = "name") String name) {
        return "provider " + name;
    }

    @GetMapping("/provider/error")
    public String error() {
        throw new RuntimeException("this is error");
    }

    @GetMapping("/provider/timeout")
    public String timeout() {
        int outTime = 6;
        try {
            TimeUnit.SECONDS.sleep(outTime);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return "线程池：" + Thread.currentThread().getName() + "  timeout, 耗时: " + outTime;
    }
}
